package com.etone.smartAudit.controller;

import com.etone.smartAudit.dto.egcc.*;
import com.etone.smartAudit.service.EGCCMService;
import com.etone.smartAudit.service.EgccSubribeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/***
 * E掌通提供接口
 */

@Api(value = "EGCC应用侧验收接口", tags = "EGCCMController验证EGCC手机号码")
@RestController
public class EGCCMController {


    @Autowired
    private EGCCMService mService;

    @Autowired
    private EgccSubribeService subribeService;

    @ApiOperation(value = "验证手机号码", tags = "EGCCMController验证EGCC手机号码")
    @ResponseBody
    @PostMapping("/egcc/verifyMobile")
    public VerifyMobileVO verifyMobile(@RequestBody VerifyDTO dto) {
        VerifyMobileVO vo = mService.verifyMobile(dto);
        return vo;
    }




    @ApiOperation(value = "订阅消息接口", tags = "EGCCMController验证EGCC手机号码")
    @ResponseBody
    @PostMapping("/egcc/app/subscribe")
    public SubscriptVO subscribe(@RequestBody SubscriptDTO dto) {
        SubscriptVO vo = subribeService.subscribe(dto);
        return vo;
    }

    @ApiOperation(value = "订阅消息接口", tags = "EGCCMController验证EGCC手机号码")
    @ResponseBody
    @PostMapping("/egcc/app/unsubscribe")
    public SubscriptVO unSubscribe(@RequestBody SubscriptDTO dto) {
        SubscriptVO vo = subribeService.unSubscribe(dto);
        return vo;
    }

    /***
     * 重定向到我们的h5页面
     * @param dto
     * @return
     */
    @ApiOperation(value = "跳转到我们的页面", tags = "EGCCMController验证EGCC手机号码")
    @GetMapping("/egcc/ownerPage")
    public String toOwnerPage(ToPageDTO dto) {
        String url = mService.toOwnerPage(dto);
//        return "redirect:https://www.baidu.com/";
//        return "forword:https://www.csdn.net/";
        return "redirect:" + url;
    }
}
